// 第一步:引入路由器
import { createRouter,createWebHistory } from "vue-router";

// 引入所有需要呈现的组件
import Home from "@/components/Home.vue";
import User from "@/components/User.vue";
import Product from "@/components/Product.vue";
import Detail from "@/components/Detail.vue";

// 第二步:创建路由器
const router = createRouter({
    history: createWebHistory(), // 路由工作模式
    routes:[{
        path: '/home',
        component: Home
    },{
        path: '/user',
        component: User,
        name: 'yh'
    },{
        path: '/product',
        component: Product,
        name: 'sp',
        children:[{
            // 嵌套的路由不能以/开头,需要省略/
            path: 'detail/:id/:name/:price',
            component: Detail,
            name: 'xq'
        }]
    }]
})

// 将路由暴露出去
export default router